<?php
$this->houseme_view->header();
?>
<!--<div id="mytagPage">-->
    <!--
    	<div id="editorMy">
            <div class="memberPhoto"></div>
            <h3>使用者名稱</h3>
            <div class="memberEditor"><a href="#">編輯帳號</a></div>
   		</div>
        <div id="myFbp">
        	<ul>
           		<li><a href="#">好友01</a></li>
                <li><a href="#">好友02</a></li>
                <li><a href="#">好友03</a></li>
                <li><a href="#">好友04</a></li>
                <li><a href="#">好友05</a></li>
                <li><a href="#">好友01</a></li>
                <li><a href="#">好友02</a></li>
                <li><a href="#">好友03</a></li>
                <li><a href="#">好友04</a></li>
                <li><a href="#">好友05</a></li>
          </ul>
        </div>
    -->
    	<!--<div class="addMyPhoto"><a href="#">創造我的俬迷本</a></div>-->

        <div id="addMyPhotoList">
            <div id="editorMy">
                <h3><?php echo $user_name; ?></h3>
                <div class="memberEditor"><a href="#">編輯帳號</a></div>
            </div>
            <?php if(!empty($user_collected)){ ?>
            <ul>
                <li class="hidden-xs hidden-sm"><div class="addMyPhoto"><a href="#">上傳我的俬分享</a></div></li>
                <?php if(!empty($user_shared)){ 
                ?>
                <li>
                    <a href="/share/<?php echo $uid; ?>"><div class="listName">我的俬分享</div>
                    <?php
                    $temp = json_decode($user_shared[0]['upload_image']);
                    $image_filename = $temp[0];
                    $img_src = $this->config->item('image_uploader_fe_thumbs','layout').'/'.$user_shared[0]['user_id'].'/'.$image_filename;

                    ?>
                    <div class="bigimg"><img src="<?php echo $img_src; ?>" style="width:200px;height:150px;"></div>        
                    <ol>
                        <?php for($i = 1; $i<=3; $i++){
                            if(isset($user_shared[$i])){
                                $temp = json_decode($user_shared[$i]['upload_image']);
                                $image_filename = $temp[0];
                                $img_src = $this->config->item('image_uploader_fe_thumbs','layout').'/'.$user_shared[$i]['user_id'].'/'.$image_filename;
                                echo '<li><img style="width:60px;height:45px;" src="'.$img_src.'"></li>';
                            }
                            else{
                                echo '<li><img style="width:60px;height:45px;" src="/assets/img/mytag/smimg.png"></li>';
                            }                            

                        }?>

                        
                    </ol>  
                    </a> 
                </li>
                <?php } ?>
            <?php foreach($user_collected as $collected_category => $post_in_category){ ?>
                <?php if(!empty($user_collected[$collected_category])){ ?>
                <li>
                    <?php
                        $replace_array = array('/','(',')');
                        $category_alias = str_replace($replace_array, '', $collected_category);
                    ?>
                <a href="<?php echo $collect_board_url.urlencode($category_alias); ?>">
                <div class="listName"><?php echo $user_collected_alias->$collected_category; ?></div>
                <?php
                    for ($i=0; $i <= 3 ; $i++) { 
                        if($i == 0 && isset($post_in_category[$i])){ // bigimg
                            if(isset($post_in_category[$i]['topic_desc'])){ // topic
                                $doc = new DOMDocument();
                                @$doc->loadHTML($post_in_category[$i]['topic_desc']);
                                $first_img = $doc->getElementsByTagName('img')->item(0);
                                $img_src = $first_img->attributes->getNamedItem("src")->value;
                            }
                            elseif(isset($post_in_category[$i]['reject_reason'])){ // share
                                $temp = json_decode($post_in_category[$i]['upload_image']);
                                $image_filename = $temp[0];
                                $img_src = $this->config->item('image_uploader_fe_thumbs','layout').'/'.$post_in_category[$i]['user_id'].'/'.$image_filename;
                            }
                            else{ // post
                                $temp = json_decode($post_in_category[$i]['upload_image']);
                                $image_filename = $temp[0];
                                $img_src = $this->config->item('image_uploader_thumbs','layout').'/'.$post_in_category[$i]['user_id'].'/'.$image_filename;
                            }
                            echo '<div class="bigimg"><img style="width:200px;height:150px;" src="';
                                echo $img_src;
                            echo '"/></div>';
                        }
                        elseif(isset($post_in_category[$i])){ // smimg : $i => 1~3
                            if($i == 1){ // first smimg
                                if(isset($post_in_category[$i]['topic_desc'])){ // topic
                                    $doc = new DOMDocument();
                                    @$doc->loadHTML($post_in_category[$i]['topic_desc']);
                                    $first_img = $doc->getElementsByTagName('img')->item(0);
                                    $img_src = $first_img->attributes->getNamedItem("src")->value;
                                }
                                elseif(isset($post_in_category[$i]['reject_reason'])){ //share
                                    $temp = json_decode($post_in_category[$i]['upload_image']);
                                    $image_filename = $temp[0];
                                    $img_src = $this->config->item('image_uploader_fe_thumbs','layout').'/'.$post_in_category[$i]['user_id'].'/'.$image_filename;
                                }
                                else{ // post
                                    $temp = json_decode($post_in_category[$i]['upload_image']);
                                    $image_filename = $temp[0];
                                    $img_src = $this->config->item('image_uploader_thumbs','layout').'/'.$post_in_category[$i]['user_id'].'/'.$image_filename;
                                }

                                echo '<ol><li><img style="width:60px;height:45px;" src="';
                                    echo $img_src;
                                echo '"/></li>';
                            }
                            elseif($i == 3){ // last smimg
                                if(isset($post_in_category[$i]['topic_desc'])){ // topic
                                    $doc = new DOMDocument();
                                    @$doc->loadHTML($post_in_category[$i]['topic_desc']);
                                    $first_img = $doc->getElementsByTagName('img')->item(0);
                                    $img_src = $first_img->attributes->getNamedItem("src")->value;
                                }
                                elseif(isset($post_in_category[$i]['reject_reason'])){ // share
                                    $temp = json_decode($post_in_category[$i]['upload_image']);
                                    $image_filename = $temp[0];
                                    $img_src = $this->config->item('image_uploader_fe_thumbs','layout').'/'.$post_in_category[$i]['user_id'].'/'.$image_filename;
                                }
                                else{ // post
                                    $temp = json_decode($post_in_category[$i]['upload_image']);
                                    $image_filename = $temp[0];
                                    $img_src = $this->config->item('image_uploader_thumbs','layout').'/'.$post_in_category[$i]['user_id'].'/'.$image_filename;
                                }
                                echo '<li><img style="width:60px;height:45px;" src="';
                                    echo $img_src;
                                echo '"/></li></ol>';
                            }
                            else{
                                if(isset($post_in_category[$i]['topic_desc'])){ // topic
                                    $doc = new DOMDocument();
                                    @$doc->loadHTML($post_in_category[$i]['topic_desc']);
                                    $first_img = $doc->getElementsByTagName('img')->item(0);
                                    $img_src = $first_img->attributes->getNamedItem("src")->value;
                                }
                                elseif(isset($post_in_category[$i]['reject_reason'])){ // share
                                    $temp = json_decode($post_in_category[$i]['upload_image']);
                                    $image_filename = $temp[0];
                                    $img_src = $this->config->item('image_uploader_fe_thumbs','layout').'/'.$post_in_category[$i]['user_id'].'/'.$image_filename;
                                }
                                else{ // post
                                    $temp = json_decode($post_in_category[$i]['upload_image']);
                                    $image_filename = $temp[0];
                                    $img_src = $this->config->item('image_uploader_thumbs','layout').'/'.$post_in_category[$i]['user_id'].'/'.$image_filename;
                                }
                                echo '<li><img style="width:60px;height:45px;" src="';
                                    echo $img_src;
                                echo '"/></li>';
                            }
                        }
                        else{ // smimg : not set
                            if($i == 1){ // first smimg
                                echo '<ol><li><img src="';
                                    echo $this->config->item('not_set_smimg_src','layout');
                                echo '"/></li>';
                            }
                            elseif($i == 3){ // last smimg
                                
                                echo '<li><img src="';
                                    echo $this->config->item('not_set_smimg_src','layout');
                                echo '"/></li></ol>';
                            }
                            else{
                                echo '<li><img src="';
                                    echo $this->config->item('not_set_smimg_src','layout');
                                echo '"/></li>';
                            }
                        }
                ?>        
                <?php            
                        
                    }
                ?>
                </a>
                <div class="editorListBtn"><a href="#" collect-name='<?php echo $user_collected_alias->$collected_category;?>'>編輯</a></div>
                </li>
                <?php } ?>

            <?php } ?>
        	</ul>
            <?php }else{ ?>
                    <!--<div id="noCollect">您尚無任何收藏喔！</div>-->
                    <ul>
                        <li><div class="addMyPhoto"><a href="#">上傳我的俬分享</a></div></li>
                    </ul>
            <?php } ?>
        </div>
        <!--
        <div style="clear:both"></div>
        <div class="addMyPhoto"><a href="#">上傳我的俬分享</a></div>
        <div id="addMyPhotoList">
        	<ul>
            	<li class="firstList">
                <div class="listName">我的俬迷本</div>
                <div class="bigimg"></div>
                <ol>
                <li></li><li></li><li></li>
                </ol>
                <div class="editorListBtn"><a href="#">編輯</a></div>
             	</li>
                
                <li><div class="listName">我的俬迷本</div>
                <div class="bigimg"></div>
                <ol>
                <li></li><li></li><li></li>
                </ol>
                <div class="editorListBtn"><a href="#">編輯</a></div></li>
                <li><div class="listName">我的俬迷本</div>
                <div class="bigimg"></div>
                <ol>
                <li></li><li></li><li></li>
                </ol>
                <div class="editorListBtn"><a href="#">編輯</a></div></li>
                <li><div class="listName">我的俬迷本</div>
                <div class="bigimg"></div>
                <ol>
                <li></li><li></li><li></li>
                </ol>
                <div class="editorListBtn"><a href="#">編輯</a></div></li>
                <li><div class="listName">我的俬迷本</div>
                <div class="bigimg"></div>
                <ol>
                <li></li><li></li><li></li>
                </ol>
                <div class="editorListBtn"><a href="#">編輯</a></div></li>
            </ul>
        </div>
        <div class="endSpan"></div>
    -->
	<!--</div>-->
<?php
$this->houseme_view->footer();
?>